<?php
require_once 'Zend/Db/Table/Abstract.php';
class InstitutesModel extends Zend_Db_Table_Abstract
{
	protected $_name = 'institutes';
	protected $_id = 'id';
	
	public static function institutes(){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('institutes');
		$list = $db->fetchAll($mySql);
		return $list;
	}
	
	/*
	 * Tim khoa tuong ung.
	 */
	public static  function getInstituteByName($name){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('institutes')
					->where("name LIKE ?",$name);
		$list = $db->fetchAll($mySql);
		if(count($list)) return $list[0]["id"];
		else return 0;
	}
	
   public function id_institutes($id){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('institutes')
					->where("id =?",$id);
		$list = $db->fetchAll($mySql);
		return $list;
	}
	
	public function get_email_institutes($email){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('institutes')
					->where("email =?",$email);
		$list = $db->fetchAll($mySql);
		return $list;
	}
	
	public function getinstitutesList(){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
		->from('institutes');
		$list = $db->fetchAll($mySql);
		return $list;
	}
	
	/*
	 * lấy ra user đầu tiên
	 */
	
	public function getUserFirts(){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('institutes')
					->limit(1,0);
		$list = $db->fetchAll($mySql);
		return $list;
	}

	/*
	*Lay ten hoc ki theo id
	*/
	 public function getNameById($id){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from('institutes')
					->where("id =?",$id);
		$list = $db->fetchAll($mySql);
		return $list[0]["name"];
	}
	

}